package com.cloud.tsp.controller;

import com.cloud.api.constants.StrVo;
import com.cloud.api.domain.tsp.CommandDetail;
import com.cloud.api.domain.tsp.CommandExecHistory;
import com.cloud.api.domain.tsp.QueryIssueHistory;
import com.cloud.core.util.R;
import com.cloud.log.annotation.Log;
import com.cloud.log.enums.BusinessType;
import com.cloud.log.enums.OperatorType;
import com.cloud.mybatis.domain.TableDataInfo;
import com.cloud.tsp.service.ICommandExecHistoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author haohaibo
 * @since 2023-11-30
 */
@RestController
@RequestMapping("/command-exec-history")
public class CommandExecHistoryController {

    @Resource
    private ICommandExecHistoryService commandExecHistoryService;

    /*@Tag(name = "v1.0")
    @Operation(summary = "执行历史（管理）")
    @PostMapping("/getExecHistory")
    @Log(title = "指令管理-执行历史", businessType = BusinessType.OTHER, operatorType = OperatorType.MANAGE)
    public R<CommandExecHistory> selectExecHistory(@RequestBody @Valid StrVo para){
        TableDataInfo<CommandExecHistory> data = commandExecHistoryService.selectExecHistory(para.getId());
        return R.ok(data.getRows());
    }*/

    @Tag(name = "v1.0")
    @Operation(summary = "指令下发历史（管理）")
    @PostMapping("/getIssueHistory")
    @Log(title = "指令管理-指令下发历史", businessType = BusinessType.OTHER, operatorType = OperatorType.MANAGE)
    public TableDataInfo<CommandExecHistory> selectIssueHistory(@RequestBody @Valid QueryIssueHistory para){
        return commandExecHistoryService.selectIssueHistory(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "查询指令执行详情（管理）")
    @PostMapping("/getCommandExecDetail")
    @Log(title = "指令管理-查询指令执行详情", businessType = BusinessType.OTHER, operatorType = OperatorType.MANAGE)
    public R<CommandDetail> selectCommandExecDetail(@RequestBody @Valid StrVo para){
        return R.ok(commandExecHistoryService.selectCommandExecDetail(para.getId()));
    }

}